﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Collections.Generic;
using Kiosk.Library;

namespace Kiosk.WebService
{
    /// <summary>
    /// This service allows clients to interact with the Kiosk system
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class NotificationService : System.Web.Services.WebService
    {

        /// <summary>
        /// Adds a notification to the kiosk with the specified information
        /// </summary>
        [WebMethod]
        public bool AddNotification(string title, string description,
            DateTime notificationDate, Guid locationID, Guid notificationTypeID)
        {

            return true ;
        }

        /// <summary>
        /// Returns all the locations in the database
        /// </summary>
        [WebMethod]
        public Dictionary<string, Guid> GetLocations()
        {
            Dictionary<string, Guid> locDic = new Dictionary<string, Guid>();
            LocationReadOnlyList locs = LocationReadOnlyList.GetAll();
            foreach (LocationInfo li in locs)
            {
                locDic.Add(li.Name, li.LocationID);
            }

            return locDic;
        }

        /// <summary>
        /// Returns all the locations in the database
        /// </summary>
        [WebMethod]
        public Dictionary<string, Guid> GetNotificationTypes()
        {
            Dictionary<string, Guid> noteDic = new Dictionary<string, Guid>();
            NotificationTypeReadOnlyList nts = NotificationTypeReadOnlyList.GetAll();
            foreach (NotificationTypeInfo nti in nts)
            {
                noteDic.Add(nti.Name, nti.NotificationTypeID);
            }

            return noteDic;
        }   

    }

    [Serializable]
    public class NameValuePair
    {
        string Name;
        Guid Id;
    }
}
